﻿using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Caching.Memory;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace InfrastructureBase.Data.Aop.Filter
{
    /// <summary>
    /// 授权，资源拦截
    /// </summary>
    public class CacheResourceFilter : Attribute, IResourceFilter
    {
        private readonly IMemoryCache cache;

        public CacheResourceFilter(IMemoryCache _cache)
        {
            cache= _cache;
        }

        private readonly int _cacheTime;
        public CacheResourceFilter(int cacheTime)
        {
            _cacheTime = cacheTime;
        }

        public void OnResourceExecuted(ResourceExecutedContext context)
        {
            Console.WriteLine("资源执行结束了");
        }

        public void OnResourceExecuting(ResourceExecutingContext context)
        {
            Console.WriteLine("资源执行开始了");
        }
    }
}
